package com.demo.zhou.sniper.zzUtil.entity;


import lombok.Data;

/**
 * 当颜色为红色时，前为大后为小，当颜色为蓝色的时候，后为大，前为小
 * <p>
 * 原始数
 *
 * @author zhizhu
 */
@Data
public class Primitive {
    /**
     * 前
     */
    private int front;
    /**
     * 后
     */
    private int back;
    /**
     * 大
     */
    private int big;
    /**
     * 小
     */
    private int small;
    /**
     * 值
     */
    private int value;
    /**
     * 颜色(红：真 ，蓝：假)
     */
    private boolean color;
    /**
     * front是否和back相同
     */
    private boolean isEquals;

    /**
     * 输入值是否为绿色
     */
    private boolean green;

    public Primitive(int value, boolean color, boolean green) {
        this.value = value;
        this.color = color;
        front = value / 10;
        back = value % 10;
        //判断L状态下输入T-K的值，并分离前后值
        if (value >= 100 && value < 1000) {
            front = value / 10;
            back = value % 10;
        } else if (value >= 1000) {
            front = value / 100;
            back = value % 100;
        }
        isEquals = front == back;
        if (color) {
            big = back;
            small = front;
        } else {
            big = front;
            small = back;
        }
        this.green = green;
    }


    private void parseInt(StringBuilder sb, int i) {
        switch (i) {
            case 0:
                sb.append("0");
                break;
            case 1:
                sb.append("1");
                break;
            case 2:
                sb.append("2");
                break;
            case 3:
                sb.append("3");
                break;
            case 4:
                sb.append("4");
                break;
            case 5:
                sb.append("5");
                break;
            case 6:
                sb.append("6");
                break;
            case 7:
                sb.append("7");
                break;
            case 8:
                sb.append("8");
                break;
            case 9:
                sb.append("9");
                break;
            case 10:
                sb.append("T");
                break;
            case 11:
                sb.append("J");
                break;
            case 12:
                sb.append("Q");
                break;
            case 13:
                sb.append("K");
                break;
        }
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        parseInt(sb, front);
        parseInt(sb, back);
        return sb.toString().intern();
    }


}